package wisp.game;

import wisp.dataObjects.Statistics;
import wisp.dataObjects.WispCharacter;

public class LevelInfo {

	//get values from database .. hard coded for now.
	public static int LEVEL1 = 0; 
	public static int LEVEL2 = 160;
	public static int LEVEL3 = 250;
	public static int LEVEL4 = 360;
	public static int LEVEL5 = 770;
	public static int LEVEL6 = 1120;
	public static int LEVEL7 = 1530;
	public static int LEVEL8 = 2000;
	public static int LEVEL9 = 2530;
	public static int LEVEL10 = 3200;
	public static int LEVEL11;
	public static int LEVEL12;
	public static int LEVEL13;
	public static int LEVEL14;
	public static int LEVEL15;
	public static int LEVEL16;
	public static int LEVEL17;
	public static int LEVEL18;
	public static int LEVEL19;
	public static int LEVEL20;
	
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}
	
	public int getExpRequired(int level)
	{
		
		switch (level)
		{
			case 1: return LEVEL1;
			case 2: return LEVEL2;
			case 3: return LEVEL3;
			case 4: return LEVEL4;
			case 5: return LEVEL5;
			case 6: return LEVEL6;
			case 7: return LEVEL7;
			case 8: return LEVEL8;
			case 9: return LEVEL9;
			case 10: return LEVEL10;
			default: return -1;
		}
	}
	
	    public void lvlUp(Statistics wcs, WispCharacter wc, int lvl)
	    {
	        this.init(wc, wcs);
	        
	        if(wc.getCClass().equals("templar"))
	            this.lvlTemplar(wc, wcs, lvl);
	        else if (wc.getCClass().equals("elementalist"))
	            this.lvlElementalist(wc, wcs, lvl);
	        else if (wc.getCClass().equals("heirophant"))
	            this.lvlHeirophant(wc, wcs, lvl);
	        
	        wcs.setARate(this.compACC(wcs));
	        wcs.setAtk(this.compBATK(wcs));
	        wcs.setMAtk(this.compBMATK(wcs));
	        wcs.setBRate(this.compBlock(wcs));
	        wcs.setCritRate(this.compCRIT(wcs));
	        wcs.setDef(this.compDEF(wcs));
	        wcs.setDRate(this.compDodge(wcs));
	        wcs.setRes(this.compRES(wcs));
	        wcs.setSpd(this.compSPD(wcs));
	    }
	    
	    public void init(WispCharacter wc, Statistics wcs)
	    {
	        String cName = wcs.getCharacterName();
	        
	        wcs.setStr(wcs.getStr()+1);
	        wcs.setDex(wcs.getDex()+1);
	        wcs.setCInt(wcs.getCInt()+1);
	        wcs.setVit(wcs.getVit()+1);
	        wcs.setSpr(wcs.getSpr()+1);
	        
	        int hp = (int) Math.ceil(wc.getMHP() * 1.1);
	        int mp = (int) Math.ceil(wc.getMMP() * 1.05);
	        
	        wc.setMHP(hp);
	        wc.setMMP(mp);
	        
	        wcs.setHpGR(wcs.getHpGR() * 1.05);
	        wcs.setMpGR(wcs.getMpGR() * 1.05);
	    }
	    
	    
	    public void lvlTemplar(WispCharacter wc, Statistics wcs, int lvl)
	    {
	        String cName = wc.getCharactername();
	        
	        int hp = (int) Math.ceil(wc.getMHP() * 1.02);
	        
	        wc.setMHP(hp);
	        wcs.setSpd(wcs.getSpd() * 1.02);
	        
	        if (lvl % 2 == 0) //every 2 levels
	        {
	        	 wcs.setStr(wcs.getStr()+1);
	        	 wcs.setVit(wcs.getVit()+1);
	        }
	        
	        if (lvl % 10 == 0) //every 10th level
	        {
	        	wcs.setStr(wcs.getStr()+2);
	            wcs.setDex(wcs.getDex()+2);
	            wcs.setVit(wcs.getVit()+2);
	        }
	        
	    }
	    
	    public void lvlHeirophant(WispCharacter wc, Statistics wcs, int lvl)
	    {
	        String cName = wc.getCharactername();
	        
	        int hp = (int) Math.ceil(wc.getMHP() * 1.02);
	        int mp = (int) Math.ceil(wc.getMMP() * 1.02);
	        
	        wc.setMHP(hp);
	        wc.setMMP(mp);
	        
	        if (lvl % 2 == 0) //every 2 levels
	        {
	        	wcs.setStr(wcs.getStr()+1);
	        	wcs.setSpr(wcs.getSpr()+1);
	        }
	        
	        if (lvl % 10 == 0) //every 10th level
	        {
	        	wcs.setStr(wcs.getStr()+2);
	        	wcs.setSpr(wcs.getSpr()+2);
	        	wcs.setVit(wcs.getVit()+2);
	        }
	    }
	    
	    public void lvlElementalist(WispCharacter wc, Statistics wcs, int lvl)
	    {
	        String cName = wc.getCharactername();
	        
	        int hp = (int) Math.ceil(wc.getMHP() * 1.05);
	        int mp = (int) Math.ceil(wc.getMMP() * 1.1);
	        int matk = (int) Math.ceil(wcs.getMAtk() * 1.02);
	        
	        wc.setMHP(hp);
	        wc.setMMP(mp);
	        wcs.setMAtk(matk);
	        
	        if (lvl % 2 == 0) //every 2 levels
	        {
	            wcs.setCInt(wcs.getCInt()+1);
	            wcs.setDex(wcs.getDex()+1);
	        }
	        
	        if (lvl % 10 == 0) //every 10th level
	        {
	        	wcs.setSpr(wcs.getSpr()+2);
	            wcs.setCInt(wcs.getCInt()+2);
	            wcs.setDex(wcs.getDex()+2);
	        }
	    }
	    
	    public double compACC(Statistics wcs)
	    {
	        //null skillT
	        double value = 0.0, ret = 0.0;
	        double acc = 0.0;
	        
	        int dex = wcs.getDex();
	                
	        value = 0.55 + (dex * 0.0025);
	        ret = (value + acc) * 100;
	        System.out.println("new acc "+ ret);
	        return ret;
	    }
	    
	    public int compBATK(Statistics wcs)
	    {
	        double value = 0.0;
	        int ret = 0;
	        
	        int str = wcs.getStr();
	        value = (str + (5 * (str/5)));
	        //value = Math.ceil(str * 1.68);
	        //System.out.println("new atk value "+ value);
	        ret = (int)value;
	        //temp = String.valueOf(Math.floor(value));
	        //ret = Integer.parseInt(temp.substring(0, temp.length()-2));
	        System.out.println("new atk "+ ret);
	        return ret;
	    }
	    
	    public int compBMATK(Statistics wcs)
	    {
	        double value = 0.0;
	        String temp = null;
	        int ret = 0;
	        
	        int intl = wcs.getCInt();
	        value = ((intl * 2) + (10 * (intl/5)));
	        //value = ((intl * 2) + (6 * (intl/5)));
	        
	        temp = String.valueOf(Math.floor(value));
	        ret = Integer.parseInt(temp.substring(0, temp.length()-2));
	        
	        System.out.println("new matk "+ ret);
	        
	        return ret;
	    }
	    
	    
	    public int compDEF(Statistics wcs)
	    {
	        int ret = 0;
	        
	        ret = (int)(wcs.getDef()*.025) + wcs.getDef();
	        System.out.println("new def "+ ret);
	        return ret;
	    }
	    
	    public int compRES(Statistics wcs)
	    {
	        int ret = 0;
	        int spr = wcs.getSpr();
	        
	        ret = (int)(spr * .05) + spr;
	        System.out.println("new res "+ ret);
	        return ret;
	    }
	    
	    public double compDodge(Statistics wcs)
	    {
	        double value = 0.0, ret = 0.0;
	        
	        value = (1 + (wcs.getDex() / 5));
	        //value = (wcs.getDex() * 1.33);
	        //ret = (value) / 100;
	        ret = value;
	        System.out.println("new dodge "+ ret);
	        return ret;
	    }
	    
	    public double compBlock(Statistics wcs)
	    {
	        double value = 0.0, ret = 0.0;
	        
	        value = (1 + (wcs.getStr() / 5));
	        //value = (wcs.getStr() * 1.47);
	        //ret = (value) / 100;
	        ret = value;
	        System.out.println("new block "+ ret);
	        return ret;
	    }
	    
	    //is used to subtract the crit stat after the pvp/curse battle
	    public double compCRIT(Statistics wcs)
	    {
	        double value = 0.0, ret = 0.0;
	        
	        int dex = wcs.getDex();
	        int intl = wcs.getCInt();
	             
	        value = 0.01 + ((dex + intl) * 0.005);
	        ret = value * 100;
	        System.out.println("new crit "+ ret);
	                
	        return ret;
	    }
	    
	    public double compSPD(Statistics wcs)
	    {
	        double value = 0.0, ret = 0.0;
	        
	        int dex = wcs.getDex();
	        value = 0.5 + ((dex / 5) * 0.05);

	        ret = value;
	        System.out.println("new spd "+ ret);
	        return ret;
	    }
}